﻿namespace D.AT.Dto
{
    public class JobAddRequestDto
    {
        public BasicInfo basicInfo { get; set; }
        public List<JobContextKeySaveRequests> jobContextKeySaveRequests { get; set; }
        public List<string> jobExcludeValueList { get; set; }
        public ChartInfo chartInfo { get; set; }
        public List<RuleConfigInfoItem> ruleConfigInfo { get; set; }
        public List<SpcCdfListItem> spcCdfList { get; set; } 
        public List<GradeAlarmListItem> gradeAlarmList { get; set; }
    }
    #region BasicInfo


    public class BasicInfo
    {
        public string ldsId { get; set; }
        public string spcFolderId { get; set; }
        public string jobId { get; set; }
        public string jobName { get; set; }
        public long fabObjectId { get; set; }
        public long moduleGroupId { get; set; }
        public string ocapTemplateId { get; set; }
        public string edcLevel { get; set; } = "WAFER";
        public string controlStatus { get; set; } = "SPC_CONTROL";
        public string tag { get; set; }
        public string jobStatus { get; set; } = "ACTIVE";
        public bool autoCreatedSubJob { get; set; } = true;
        public bool onlySubjob { get; set; } = false;
        public string normalizaTionModelEnum { get; set; } = "NOTNORMALIZATION";
        public string movingChartReset { get; set; } = "2024-01-01 00:00:00";
        public bool collectionIntervalOccurs { get; set; } = false;
        public string collectionIntervalDays { get; set; }
        public string collectionIntervalHours { get; set; }
        public string collectionIntervalTemplate { get; set; }
        public string matchingId { get; set; }
        public string inlineType { get; set; } = "Inline";
        public bool keyChart { get; set; } = false;
        public List<string> alarmMailTypes { get; set; } = new List<string>() { "ALARM_OCCURS" };
        public bool subJob { get; set; } = false;
        public bool matchingInherit { get; set; } = false;
        public bool autoSubJobInherit { get; set; } = false;
        public bool mailTemplateInherit { get; set; } = false;
        public bool collectionIntervalInherit { get; set; } = true;
        public bool collectionIntervalTemplateInherit { get; set; } = false;
        public SubJobInherit subJobInherit { get; set; } = new SubJobInherit();
        public bool chartDisplayInherit { get; set; } = true;
        public string displayType { get; set; } = "1";
        public string showGraphics { get; set; }
        public string effectiveDate { get; set; } = "2024-01-01 00:00:00";
        public string dataType { get; set; } = "Variable";
        public string gradeAlarmId { get; set; }
        public string mailTemplate { get; set; }
        public int mailChartPointNum { get; set; } = 25;
        public MailTo mailTo { get; set; }
        public MailCc mailCc { get; set; }
        public string collectionIntervalMailTo { get; set; }
        public string collectionIntervalMailCc { get; set; }
    }
    public class SubJobInherit
    {
        public bool controlStatusInherit { get; set; } = false;
        public bool ocapTemplateIdInherit { get; set; } = false;
        public bool movingChartResetInherit { get; set; } = false;
        public bool jobStatusInherit { get; set; } = false;
        public bool alarmOccursInherit { get; set; } = false;
        public bool collectedMoreSubJobInherit { get; set; } = false;
        public bool collectionIntervalSubJobInherit { get; set; } = false;
        public bool outlierInherit { get; set; } = false;
        public bool screenLimitInherit { get; set; } = false;
        public bool chartTypeInherit { get; set; } = false;
    }

    public class MailTo
    {
        public List<string> groupIds { get; set; }
        public List<string> userIds { get; set; }
    }

    public class MailCc
    {
        public List<string> groupIds { get; set; }
        public List<string> userIds { get; set; }
    }
    #endregion

    #region JobContextKeySaveRequests


    public class JobContextKeySaveRequests
    {
        public int columnIndex { get; set; }
        public string value { get; set; }
    }
    #endregion

    #region ChartInfo
    public class ChartInfo
    {
        public string unit { get; set; } = "um";
        public Outlier outlier { get; set; }
        public List<string> chartTypes { get; set; } = new List<string>()
        {
            "XBAR",
            "TREND",
            "R",
            "S"
        };
        public List<ChartConfigsItem> chartConfigs { get; set; }
        public ControlItem controlItem { get; set; }
    }
    public class Outlier
    {
        public string lower { get; set; } = "-100";
        public string upper { get; set; } = "1500";
    }
    public class ControlConfig
    {
        public string limitType { get; set; }
        public string cl { get; set; }
        public string lcl { get; set; }
        public string ucl { get; set; }
        public bool clDisable { get; set; } = false;
        public bool lclDisable { get; set; } = false;
        public bool uclDisable { get; set; } = false;
    }

    public class SpecConfig
    {
        public string limitType { get; set; }
        public string lsl { get; set; }
        public string target { get; set; }
        public string usl { get; set; }
        public bool lslDisable { get; set; } = false;
        public bool targetDisable { get; set; } = false;
        public bool uslDisable { get; set; } = false;
    }

    public class ScreenConfig
    {
        public string uscrl { get; set; } = "1200";
        public string lscrl { get; set; } = "10";
    }
    public class ChartConfigsItem
    {
        public string chartType { get; set; }
        public ControlConfig controlConfig { get; set; }
        public SpecConfig specConfig { get; set; }
        public ScreenConfig screenConfig { get; set; }
        public string warningLimit { get; set; } = "3";
    }
    public class ControlItem
    {
        public string variableControlItem { get; set; } = "V1";
        public List<string> variableDcItems { get; set; }
        public string attributeControlItem { get; set; } = "V1";
        public List<string> attributeDcItems { get; set; } 
    }
    #endregion

    #region RuleConfigInfo
    public class RuleConfigInfoItem
    {
        public ChartType chartType { get; set; } = new ChartType();
        public List<RuleHoldActionItem> ruleHoldAction { get; set; } = new List<RuleHoldActionItem>();
        public long ruleObjectId { get; set; }
        public bool actionSwitch { get; set; } = false;
        public List<string> ocapFlowList { get; set; } = new List<string>();
        public string ruleCode { get; set; }
    }
    public class ChartType
    {
        public bool XBAR { get; set; } = true;
        public bool TREND { get; set; } = true;
        public bool R { get; set; } = true;
        public bool S { get; set; } = true;
    }

    public class RuleHoldActionItem
    {
        public string equip { get; set; }
        public bool holdAction { get; set; } = true;
        public string holdType { get; set; } = "Hold Lot";
        public int caId { get; set; } = 301;
    }
    #endregion

    #region SpcCdfList
    public class SpcCdfListItem
    {
        public int seqNo { get; set; } = 1;
        public string name { get; set; } = "Key Chart";
        public string value { get; set; } = "KEY(Y)";
        public string dataType { get; set; } = "String";
    }
    #endregion

    #region GradeAlarmListItem
    public class GradeAlarmListItem
    {
        public string id { get; set; }
        public string alarmType { get; set; }
        public List<string> alarmTools { get; set; }
        public string alarmTo { get; set; }
        public string alarmCc { get; set; }
        public int alarmTemplateId { get; set; }
        public bool jobIdFlag { get; set; }
    }
    #endregion
}
